import { CommandId } from "@ap/command";
import { DeepPartial } from "./util";
import { ConfigurationItem } from "@ap/util/vscode/setInsConfig";
import * as vscode from "vscode";

export type PackageConfig = Record<string, any> & {
  npmPackage?: "server" | "client";
  file: {
    typescript: {
      server: {
        base?: string;
        entry: string;
        ECS?: boolean;
        development?: boolean;
        webpack?: string;
        esbuild?: boolean;
      };
      client: {
        base?: string;
        entry: string;
        ECS?: boolean;
        development?: boolean;
        webpack?: string;
        esbuild?: boolean;
      };
      developmentAll?: boolean | null;
      jsUpdate?: boolean;
    };
  };
  outputAndUpdate?:
    | string[]
    | {
        name: string;
        serverEntry: string;
        clientEntry: string;
        description?: string;
      }[];
  map: {
    id: string;
    editHash: string;
    playHash?: string;
  };
};

// /**
//  * 初始化配置对象。
//  *
//  * 此对象用于配置项目的文件组织结构和一些关键标识信息。
//  */
// export const initializeConfig: PackageConfig = {
//     "file": {
//         "typescript": {
//             "server": {
//                 entry: "./server"
//             },
//             "client": {
//                 entry: "./client"
//             }
//         },
//     },
//     "map": {
//         "id": "",
//         "editHash": "",
//         "playHash": ""
//     }
// };
export type UserPackageConfig = DeepPartial<PackageConfig>;

interface UserData {
  userId: number;
  nickname: string;
  email: string;
  avatar: string;
  avatarFrame: string;
  previewUrl: string;
  birthday: string;
  gender: number;
  language: string;
  phone?: any;
  token: string;
  hasSetPwd: boolean;
  hasAuthenticated: boolean;
  wallet?: any;
  authType: number;
  walletType?: any;
  certType: number;
  userBankCardNum?: any;
  permission: number;
  appId: string;
}

export interface UserDataRootObject {
  code: number;
  msg: string;
  data: UserData | null;
  traceId: string;
}

export function openNodeSetting() {
  vscode.commands.executeCommand(
    CommandId.ap_openSettings,
    "@ext:box3lab.box3arenapro " + ConfigurationItem.NODEJS_TOOL,
  );
}
